This code will provide information on oil spills and their location throughout California State. A t-map will be produced as an interactive mode of exploring the data and a second static choropleth graph will be used to show a larger picture of the data within each county.
California Department of Fish and Game & Office of Spill Prevention and Response. (20089, July 23). Oil Spill Incident Tracking. Digital map and vector digital data. https://map.dfg.ca.gov/metadata/ds0394.html#ID0EUGA
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
# attach packages
library(tidyverse)
library(here)
library(maptools)
library(sf)
library(tmap)
library(tmaptools)
library(janitor)
oil_spills_sf <- read_sf(here("data/ds394/ds394.shp")) %>%
clean_names() %>%
st_transform(3310)
ca_counties <- read_sf(here("data/CA_Counties/CA_Counties_TIGER2016.shp")) %>%
clean_names() %>%
st_transform(3310)
tmap_mode(mode = "view")
tmap_options(check.and.fix = TRUE,
max.categories = 58)
tm_shape(ca_counties) +
tm_fill("aland",
palette = "BuGn",
popup.vars = c("County:" = "namelsad")) +
tm_borders(col = "black") +
tm_shape(oil_spills_sf) +
tm_dots(popup.vars = c("Control Number:" = "oesnumber",
"Date:" = "dateofinci",
"Time:" = "timeofinci",
"County:" = "localecoun",
"City:" = "localecity",
"Type of Water:" = "specificlo",
"Inland or Marine:" = "inlandmari"),
size = 0.02)